<template>
	<view class="content">
		<view @click="addUser" style="display: flex;flex-direction: column; width: 750rpx;background: white;padding: 6rpx 16rpx;">
			<view class="list-cell" style="padding: 0px;">
				<image src="/static/images/icon_adduser.png" style="width: 100rpx;height: 100rpx;"
					mode=""></image>
				<view class="name-view" style="font-weight: bold;display: flex;justify-content: space-between;">
					<span>添加好友</span>
					<view style="padding-right: 16rpx;">
						<u-icon name="arrow-right" />
					</view>
				</view>
			</view>
		</view>
		
		<view style="width: 750rpx;height: 10rpx;">
			
		</view>
		
		<view style="display: flex;flex-direction: column;">
			<view style="width: 750rpx;padding: 0rpx 10rpx;background: white;" v-for="(item,key) in data">
				<myapplyitem v-if="$store.state.user.user.id == item.from_id" :data="item" />
				<userapplyitem :changeApply="changeApply" v-else :data="item" />
			</view>
		</view>
	</view>
</template>

<script>
	import myapplyitem from './components/myapplyitem.vue'
	import userapplyitem from './components/userapplyitem.vue'
	export default {
		data(){
			return {
				data:[]
			}
		},
		components:{
			myapplyitem,userapplyitem
		},
		async onLoad() {
			const ret = await this.$u.get(`/user/user/getApplys`,{id:this.$store.state.user.user.id})
			this.data = ret.data ?? []
		},
		methods:{
			addUser:function(){
				uni.navigateTo({
					url:"/pages/address/adduser/index"
				})
			},
			getStatusInfo:function(status){
				if(status == 0){
					return "待验证"
				}else if(status == 1){
					return "已添加"
				}else{
					return "已拒绝"
				}
			},
			changeApply:function(id,status){
				for(let o of this.data){
					if(o.id == id){
						o.status = status
						break
					}
				}
			}
		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #f3f3f3;
		height: 100vh;
	}
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 0px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
		align-items: center;
	}
	.name-view {
		margin-left: 16rpx;
		flex: 1;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		padding: 10px 0px;
	}
	.info-view {
		margin-left: 16rpx;
		flex: 1;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		padding: 1rpx 0px;
		display: flex;
		flex-direction: column;
	}
</style>